package com.cskaoyan.market.util;

import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/20 23:20
 */
public class ValidationUtil {
    public static Object validate(BindingResult bindingResult){
        if(bindingResult.hasErrors()){
            FieldError fieldError=bindingResult.getFieldError();
            String field=fieldError.getField();
            String defaultMessage=fieldError.getDefaultMessage();
            return ResponseUtil.fail(401,defaultMessage);
        }
        return null;
    }
}
